home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 725 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: news.crd.ge.com!usenet
  2. From: Christopher R Volpe <volpe@ash.crd.ge.com>
  3. Newsgroups: comp.std.c
  4. Subject: Re: It this portable?
  5. Date: Thu, 11 Apr 1996 14:38:35 -0400
  6. Organization: GE Corporate Research & Development, Schenectady, NY
  7. Message-ID: <316D51AB.C23@ash.crd.ge.com>
  8. References: <Dpp1tv.4Kq@ukpsshp1.serigate.philips.nl>
  9. NNTP-Posting-Host: bart.crd.ge.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
  14.  
  15. Stephen Baynes wrote:
  16. > In a glossy newsletter from a company (who had better remain nameless) that
  17. > sells tools for testing and validating C code the following bit of code was
  18. > given as an example of implementation dependent but portable code across ISO
  19. > C implementations. I know 'portable' is not a term used in the standard
  20.  
  21. Correct.
  22.  
  23. , let
  24. > us assume it means conforming.
  25.  
  26. Bad choice. The term "conforming", when applied to user code (not to
  27. implementations) is virtually meaningless. The U.S. Constitution is a
  28. conforming piece of C code, or at least could be, given the existence of
  29. a hypothetical compiler which makes it so.
  30.  
  31. I suspect the intended characteristic here is one that has been
  32. informally dubbed "strongly conforming", meaning it violates no syntax
  33. rule or semantic constraint, and does not invoke undefined behavior.
  34.  
  35. > Is this program conforming, giving an
  36. > implementation defined result (regardless of the fact the result is probably
  37. > not the one intended) or is it going to give undefined behaviour?
  38. > #include <stdio.h>
  39. > #include <limits.h>
  40. > int main( void )
  41. > {
  42. >     printf( "%d", UINT_MAX );
  43. >     return 0;
  44. > }
  45. > My vote is for undefined, but can anyone construct an argument based on
  46. > the represention of integers that makes it implmentation defined?
  47.  
  48. Well, my vote is for implementation-defined, or at worst, unspecified,
  49. but I can be convinced otherwise. Ints and unsigned-ints are required to
  50. be the same size, I believe, and so the  result should depend only on
  51. the interpretation of the UINT_MAX bit pattern as a signed int.
  52.  
  53. My gut feeling is that there's no reason why a reasonable implementation
  54. should crash from the above code.
  55.  
  56. --
  57.  
  58. Chris Volpe                Phone: (518) 387-7766 (Dial Comm 8*833
  59. GE Corporate R&D            Fax:   (518) 387-6560
  60. PO Box 8, Schenectady, NY 12301        Email: volpecr@crd.ge.com
  61.